import 'dart:math';

import 'package:ai_desktop_eidtor/common/y_text.dart';
import 'package:ai_desktop_eidtor/main/home/setting/setting_view.dart';
import 'package:ai_desktop_eidtor/main/home/start/start_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'home_logic.dart';
import 'home_state.dart';

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final HomeLogic logic = Get.put(HomeLogic());
    final HomeState state = Get.find<HomeLogic>().state;

    return Scaffold(
      body: Obx(
        () => Row(
          children: [
            NavigationRail(
              onDestinationSelected: (p) {
                logic.changeIndex(p);
              },
              destinations: [
                NavigationRailDestination(
                  icon: Icon(Icons.book),
                  label: YText(text: '分类'),
                ),
                NavigationRailDestination(
                  icon: Icon(Icons.settings),
                  label: YText(text: '设置'),
                ),
              ],
              minWidth: 80,
              selectedIndex: logic.currentIndex.value,
            ),
            VerticalDivider(width: 1, color: Colors.grey),
            Expanded(child: logic.currentIndex.value == 0 ? StartPage() : SettingPage()),
          ],
        ),
      ),
    );
  }
}
